# -*- coding: utf-8 -*-
# Author: areful
#
# pip install grpcio
# pip install protobuf
# pip install grpcio-tools
# ...

# Copyright 2015, Google Inc.
# All rights reserved.

"""The Python implementation of the GRPC helloworld.Greeter server."""

import time
from concurrent import futures

from bqtool.rpc.algorpc_pb2 import *
from bqtool.rpc.algorpc_pb2_grpc import *

_ONE_DAY_IN_SECONDS = 60 * 60 * 24


class Algoapi(AlgoapiServicer):

    def invoke(self, request, context):
        return result(jsondata=[{"jsondata":{"s":"a"}}])


def serve():
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    add_AlgoapiServicer_to_server(Algoapi(), server)
    server.add_insecure_port('[::]:50051')
    server.start()
    try:
        while True:
            time.sleep(_ONE_DAY_IN_SECONDS)
    except KeyboardInterrupt:
        server.stop(0)


if __name__ == '__main__':
    serve()